package cn.xiyun.xiyuncc.consumerListener;

import cn.xiyun.xiyuncc.domain.MediaFile;
import cn.xiyun.xiyuncc.result.JSONResult;
import cn.xiyun.xiyuncc.service.impl.MediaFileServiceImpl;
import com.alibaba.fastjson.JSON;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

// 交给spring管理
@Component//message_test_topic
@RocketMQMessageListener(
        consumerGroup = "xiyuncc-service-media",
        topic = "service-mediaFile-producer",
        selectorExpression = "mediaFile-uploading")
public class MediaFileConsumer implements RocketMQListener<String> {
    @Autowired
    private MediaFileServiceImpl mediaFileService;
    @Override
    public void onMessage(String s) {
        MediaFile mediaFile = JSON.parseObject(s, MediaFile.class);
        JSONResult jsonResult = mediaFileService.handleFile2m3u8(mediaFile);

    }
}
